﻿using Core.RedPoint;

namespace Core
{
    public class RedPointSystem : Core.Component, IAwake
    {
        private RootNode root;

        public virtual void Awake()
        {
            root = G.Factory.Create<RootNode>();
        }

        public override void Dispose()
        {
            if (IsDisposed) return;

            root.Dispose();
            root = null;

            base.Dispose();
        }

        public void Add<T>(string[] keys)
            where T : Component, IRedPointNode
        {
            if (keys.Length == 0) return;

            root.Add<T>(keys, 0);
        }

        public T Get<T>(string[] keys)
            where T : Component, IRedPointNode
        {
            if (keys.Length == 0)
            {
                return default;
            }
            return root.Get<T>(keys, 0);
        }
    }
}
